home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / trashfile.bat < prev    next >
DOS Batch File  |  1994-06-30  |  1KB  |  45 lines

  1. @echo off
  2. !  trashfile.bat    Batch file to move a file to the system Trash
  3. !
  4. !  trashfile name
  5. !
  6. !  where 'name' is the file to be trashed. The name can be preceded by
  7. !  a path and a volume ID.
  8. !
  9. !  trashfile.bat calls extractName and uniqueName
  10. !
  11. !  Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
  12. !
  13.  
  14.     set trashfile_trash=1:\Trash
  15.  
  16.     ! ensure that the first parameter is there and that the second one is not
  17.     set doserr=13
  18.     if not "%2 " == " " goto ERR_LBL
  19.     if "%1 " == " " goto ERR_LBL
  20.  
  21.     ! ensure that the requested file is there
  22.     set doserr=27
  23.     if not exist "%1" goto ERR_LBL
  24.  
  25.     ! make a file name to be used in the trash
  26.     set doserr=0
  27.     onerror ERR_LBL
  28.     call extractName "%1" trashfile_name
  29.     if not %doserr% == 0 goto ERR_LBL
  30.     call uniqueName "%trashfile_trash%\%trashfile_name%" trashfile_name
  31.     if not %doserr% == 0 goto ERR_LBL
  32.  
  33.     ! copy the file to the trash and remove the original
  34.     copy "%1" "%trashfile_trash%\%trashfile_name%"
  35.     del "%1"
  36.     goto DONE_LBL
  37.  
  38. :ERR_LBL
  39.     show %doserr%
  40.  
  41. :DONE_LBL
  42.     ! remove the global variables
  43.     set trashfile_name=
  44.     set trashfile_trash=
  45.